package cn.panda.edu.service.impl;

import cn.panda.edu.dao.CoursewareMapper;
import cn.panda.edu.model.Courseware;
import cn.panda.edu.service.StudentResourceService;
import cn.panda.edu.util.Constant;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 * 类描述：  学生端资源文件
 * @author: 顾军伟
 * @date： 2018-01-18 8:27:36 PM
 */
@Service
public class StudentResourceServiceImpl implements StudentResourceService {

	@Autowired
	private CoursewareMapper coursewareMapper ;
	@Override
	public Courseware getResource(Integer id) {
		return coursewareMapper.selectByPrimaryKey(id) ;
	}

	@Override
	public PageInfo<Courseware> listResources(Integer pageIndex, Map<String, Object> condition) {
		Page<Courseware> pageLiStudyResources = PageHelper.startPage(pageIndex, Constant.PAGE_SIZE) ;
		coursewareMapper.selectByPageAndCondition(condition) ;
		PageInfo<Courseware> pageInfo = new PageInfo<Courseware>(pageLiStudyResources) ;
		return pageInfo ;
	}

}
